package com.tyk.bookstore.back.storage.service.impl;

import com.tyk.bookstore.back.storage.model.entity.StockDo;
import com.tyk.bookstore.back.storage.repository.StockRepository;
import com.tyk.bookstore.back.storage.service.StockApiService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

/**
 * @author tyk
 * @description StockApiServiceImpl
 */
@Service
@RequiredArgsConstructor
public class StockApiServiceImpl implements StockApiService {
    private final StockRepository stockRepository;

    @Override
    public Boolean hasStock(Long bookId) {
        return stockRepository.exist1Eq(
                StockDo::getBookId, bookId, StockDo.class
        );
    }
}
